package dpe;

import org.lwjgl.input.Keyboard;

public class Player extends GameObject {
	
	private float speed = 0.1f;

	public Player(World world, String name, Vec3 pos) {
		super(world, name, pos);
	}

	public void update() {
		if (world.game.hasFPSControl()) {
			if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
				vel.x -= speed * Math.sin(Math.toRadians(rot.x));
				vel.z += speed * Math.cos(Math.toRadians(rot.x));
			}

			if (Keyboard.isKeyDown(Keyboard.KEY_S)) {
				vel.x += speed * Math.sin(Math.toRadians(rot.x));
				vel.z -= speed * Math.cos(Math.toRadians(rot.x));
			}

			if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
				vel.x -= speed * Math.sin(Math.toRadians(rot.x - 90));
				vel.z += speed * Math.cos(Math.toRadians(rot.x - 90));
			}

			if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
				vel.x -= speed * Math.sin(Math.toRadians(rot.x + 90));
				vel.z += speed * Math.cos(Math.toRadians(rot.x + 90));
			}

			if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
				vel.y += speed;
			}

			if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
				vel.y -= speed;
			}
			
			if (rot.y < -90) {
				rot.y = -90;
			}
			if (rot.y > 90) {
				rot.y = 90;
			}
		}
	}

	public void render() {

	}

}
